/*
 * StringUtils.java
 *
 * Created on 29 March 2012, 14:19
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Simulation.Utils;

//test

/**
 *
 * @author aking2
 */
public class StringUtils {
    
    /**
     * This is the system file seperator (a slash).
     */
    public static String slash = System.getProperty("file.separator");   
    
    /**
     * This is the system line seperator (carriage return).
     */
    public static String cr = System.getProperty("line.separator");         
    
    
    /**
     * Tells you if string a contain string b
     * 
     * @param a String a
     * @param b String b
     * @return True if a contains b, otherwise False.
     */
    public static boolean Contains(String a, String b) {
        boolean result;
        result = a.indexOf(b) >=0;
        return result;
    }       
    
    /**
     * This tells you if a given string is white space or not
     *
     * @param in Given string to test
     * @return True if 'in' is whitespace, otherwise False.
     */
    public static boolean IsWhiteSpace( String in ) {
        
        boolean result = true;
        String whiteSpaces = " \t" + cr;

        for (int i=0; i< in.length(); i++) {

            if (Contains(whiteSpaces,in.subSequence(i,i+1).toString()) == false) {
                result = false;
            }
        }

        return result;
    }
    
}
